/**
 * Types
 */
import type { DeviceManagerType } from '../typings';

export const DeviceManager: DeviceManagerType = {
    /**
     * 创建的设备实例
     */
    deviceInstance: [],

    /**
     * 扫描的设备列表
     */
    deviceScan: [],

    /**
     * 调试模式：未完成，目的是：本地mock使用。
     */
    debugger: false,

    /**
     * 日志模式：
     */
    loglevel: 'warn',

    log: function (...msg: any[]) {
        if (['log'].includes(this.loglevel)) {
            console.log('%cSDK', 'padding: 2px 4px; background: #1D99F2; border-radius: 4px; color: #fff;', ...msg);
        }
    },
    info: function (...msg: any[]) {
        if (['log', 'info'].includes(this.loglevel)) {
            console.info('%cSDK', 'padding: 2px 4px; background: #1D99F2; border-radius: 4px; color: #fff;', ...msg);
        }
    },
    warn: function (...msg: any[]) {
        if (['log', 'info', 'warn'].includes(this.loglevel)) {
            console.warn('%cSDK', 'padding: 2px 4px; background: #1D99F2; border-radius: 4px; color: #fff;', ...msg);
        }
    },
    error: function (...msg: any[]) {
        if (['log', 'info', 'warn', 'error'].includes(this.loglevel)) {
            console.error('%cSDK', 'padding: 2px 4px; background: #1D99F2; border-radius: 4px; color: #fff;', ...msg);
        }
    },

    /**
     * 任务列表
     */
    tasks: {},

    /**
     * 重置reset的内容
     */
    reset: function () {
        this.deviceInstance = [];
        this.deviceScan = [];
        this.debugger = false;
        this.loglevel = 'warn';
    },
};

export default DeviceManager;
